package cn.pzh.amqp.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutConfig {
    //交换机
    @Bean
    public FanoutExchange fanoutExchange(){
       return new FanoutExchange("fanout");
    }
    //队列1
    @Bean
    public Queue queue1(){
        return new Queue("fanout.queue1");
    }
    //队列2
    @Bean
    public Queue queue2(){
        return new Queue("fanout.queue2");
    }
    //绑定队列1到交换机上
    @Bean
    public Binding binding1(FanoutExchange fanoutExchange,Queue queue1){
       return BindingBuilder.bind(queue1)
               .to(fanoutExchange);
    }
    //绑定队列1到交换机上
    @Bean
    public Binding binding2(FanoutExchange fanoutExchange,Queue queue2){
        return BindingBuilder.bind(queue2)
                .to(fanoutExchange);
    }
    //消息队列的消息转换
    @Bean
    public Queue objectQueue(){
        return new Queue("object.queue");
    }
}
